
import React, { Component } from 'react';
// 1.0 使用React.createContenxt得到两个组件
// Provider:负责进行数据传递
// Consumer：负责进行数据接收
let { Provider, Consumer } = React.createContext();

class Parent5 extends Component {
    state = {}
    render() {
        return (<div>
            <div>
                Parent5
            </div>
            <Provider value="这是Parent5中的数据">
                <Child6></Child6>
            </Provider>
        </div>);
    }
}

export default Parent5;


class Child6 extends Component {
    state = {}
    render() {
        return (<div>
            <div>Child6</div>
            <Child7></Child7>
        </div>);
    }
}


class Child7 extends Component {
    state = {}
    render() {
        return (<div>
            <div>Child7</div>
            <Consumer>
                {
                    (data) => <span>{data}</span>
                }
            </Consumer>
        </div>);
    }
}
